#include <stdio.h>
#include <string.h>

static int min = 0;
static int max = 0;
static int increment = 0;
static char operation = '*';

int countDigits(long long number) {
    int counter = 0;

    for (; number !=0; ++counter) {
        number /= 10;
    }

    return counter;
}

int chooseOperator(int firstNumber, int secondNumber) {
    if (operation == '+') {
        return (firstNumber + increment) + (secondNumber + increment);
    }
    else if (operation == '-') {
        return (firstNumber + increment) - (secondNumber + increment);
    }
    else if (operation == '*') {
        return (firstNumber + increment) * (secondNumber + increment);
    }
    else if (operation == '/') {
        return (firstNumber + increment) / (secondNumber + increment);
    }
    return 0;
}

int findLimit() {
    if (operation == '+') {
        return (max + max);
    }
    else if (operation == '-') {
        return (max - max);
    }
    else if (operation == '*') {
        return (max * max);
    }
    else if (operation == '/') {
        return (max / max);
    }
    return 0;
}

void printTable() {
	for ( int i = min; i <= max; ++i )
	{
		for ( int j = min; j <= max; ++j ) {

			if (i == min && j == min) {
                printf("%*c ", countDigits(findLimit()), operation);
			}
			//edge numbers
			else if (i == min && j != min) {
                printf("%*i ", countDigits(findLimit()), i + increment);
			}
			else if (i != min && j == min) {
                printf("%*i ", countDigits(findLimit()), j + increment);
			}
			/*//edges
			if ((i == min+increment && j == min+increment)||(i == min+increment && j != min+increment)||(i != min+increment && j == min+increment)) {
                printf("%*c ", countDigits(findLimit()), '*');
			}*/

			else {
			    printf("%*i ", countDigits(findLimit()), chooseOperator(i-2, j-2));
			}
		}
		printf("\n");
	}
}

int main()
{
    printf("Minimo: ");
	scanf("%i", &min);

	printf("Maximo: ");
	scanf("%i", &max);

	printf("Incremento: ");
	scanf("%i", &increment);

	printf("Operador: ");
	fflush(stdin);
	scanf("%c", &operation);

	printTable();

	return 0;
}
